package logic.nodes.nodeSettings.upgrades;

import java.util.HashMap;

import logic.nodes.nodeSettings.AbstractOption;

public class UpgradableOption extends AbstractOption {
	
	private int level;
	private HashMap<String, UpgradeValue> values;
	
	public UpgradableOption(String key, HashMap<String, UpgradeValue> values) {
		super(key);
		this.values = values;
		level = 0;
	}
	
	@Override
	public String getValue() { return getValueOfLevel(level); }
	
	public int getLevel() { return level; }
	
	public String getValueOfLevel(int level) {
		UpgradeValue value = values.get(level + "");
		if(value == null) return null;
		return value.getValue();
	}
	
	public int getUpgradeCosts() {
		UpgradeValue value = values.get(level + 1 + "");
		if(value == null) return 0;
		return value.getUpgradeCosts();
	}
	
	public int getMaxLevel() { return values.size() - 1; }
	
	public void upgrade() { if(!isFullyUpgraded()) level++; }
	
	public boolean isFullyUpgraded() { return getMaxLevel() == level; }
	
	public HashMap<String, UpgradeValue> getValues() { return values; }
	
	public void reset() { level = 0; }
}